/**
 * @fileOverview hover group
 * @author huangtonger@aliyun.com
 */
const Page = require('../page');

Page.registerBehaviour('hoverGroupActived', page => {
  const graph = page.getGraph();
  graph.behaviourOn('mouseenter', ev => {
    if (page.getSignal('panningItem') || (ev.item && ev.item.isSelected) || page.getSignal('dragEdge')) {
      return;
    }
    if (ev.shape && ev.shape.isGroupKeyShape) {
      page.css({
        cursor: 'move'
      });
      page.setActived(ev.item, true);
    }
  });
  graph.behaviourOn('group:mouseleave', ev => {
    if (ev.item.isActived && !ev.item.isSelected) {
      page.setActived(ev.item, false);
    }
  });
});
